home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / progut~1 / stdwin.zoo / MANUAL < prev    next >
Encoding:
Text File  |  1989-10-17  |  46.9 KB  |  1,193 lines

  1. STDWIN -- STANDARD WINDOWS
  2. --------------------------
  3. RATIONALE
  4. ---------
  5.  
  6. STDWIN was born by the desire to make using windows both easier and more
  7. portable for a certain class of applications.  To show why it should be
  8. easier than it currently is, consider for example the calls necessary to
  9. create a window on the Apple Macintosh:
  10.  
  11.     WindowPtr w;
  12.     Rect r;
  13.     
  14.     SetRect(&r, <desired window coordinates>);
  15.     w= NewWindow(
  16.         (Ptr)nil,        /* Optional storage */
  17.         &r,            /* Initial position/size */
  18.         documentProc,        /* Border frame type */
  19.         "Untitled",        /* Title */
  20.         true,            /* Immediately visible */
  21.         0L,            /* Reference constant */
  22.         (WindowPtr)-1        /* Behind no other window */
  23.     );
  24.  
  25. Since I'm doing this without documentation, I may have missed or
  26. reversed some parameters, which shows exactly what I want to illustrate:
  27. the call has too many options, most of which are of no interest to most
  28. application programmers.  Also, it forces the programmer to invent an
  29. initial position for the window, which is often a burden, since this
  30. means one also has to invent a scheme by which to offset the position
  31. for subsequent windows, to avoid creating windows that overlap exactly.
  32.  
  33. What this example doesn't show is the amount of code one has to write
  34. to provide the functionality that Mac users expect from even the
  35. simplest application: windows can be moved, resized, zoomed, closed,
  36. (de)activated, scrolled in two directions, and need to be explicitly
  37. redrawn when they pop up from below another window; none of this is done
  38. automatically by the window manager.  One needs hundreds of lines of
  39. code to provide all this functionality, and most of it has to be
  40. interspersed with application-dependent code (such as to actually draw a
  41. window's contents), which makes it harder to reuse the same code in the
  42. next program one writes.
  43.  
  44. There are other burdens to the application programmer who writes for the
  45. Macintosh, such as the large number of #include files that one must put
  46. in even the simplest programs, and the correspondingly large number of
  47. initialization calls one must make.
  48.  
  49.  
  50. Why using windows should be made more portable is clear if one considers
  51. what is necessary to port a program to a different machine like the
  52. Atari ST, the Commodore Amiga, or a Sun/3 running Suntools or X Windows
  53. (while all these use the same type of processor!).  Not only are the
  54. calls that interface to their window managers different, the semantics
  55. of windows are also subtly different.  Some systems remember a window's
  56. contents when it is covered by another window, so 'update events' are
  57. unheard of; some systems provide a standard interface to scroll bars or
  58. other tools; etc., etc.
  59.  
  60. This seriously limits productivity of application programmers: it can
  61. take many person-months to port a successful program to a new machine,
  62. even though one has used a high-level programming language such as C or
  63. Pascal.  While this effort may be economically justifyable for
  64. bestsellers like commercial spreadsheets or wordprocessors, there is a
  65. large class of applications where one can simply not afford these
  66. porting efforts, especially in the academic world, but also for many
  67. specialized applications which aim at a more limited market.
  68.  
  69.  
  70. The current design places an emphasis on full-function windows that give
  71. a scrollable 'view' on some kind of two-dimensional document, e.g. a
  72. program text editor or a graphics design program.  It provides some
  73. tools for simple modal input (e.g., to ask for a string or a file name)
  74. and gives a clean but powerful interface to the common types of pop-up
  75. or pull-down menus (with text items only).  What is clearly missing is a
  76. mechanism to put indicators, icons, controls, rulers, palettes, tool
  77. wells and other gadgets in the window border or on the 'desktop', and
  78. the ability to pop up a collection of gadgets in a dialog window as
  79. commonly seen on the Mac.  Suggestions for a general mechanism here
  80. which fits in STDWIN's philosophy are welcome.  (Are there any other
  81. systems besides the Macintosh and its derivatives like the ST or the
  82. Amiga that provide tools for controls and dialogs?)
  83.  
  84. I haven't placed too much emphasis on the design of the graphics
  85. primitives that must be used to draw the contents of a window.  There
  86. are simple routines to draw text strings in a single proportionally
  87. spaced font with a few stylistic variations, and to do simple line
  88. drawings and a few rasterop operations on rectangles.  I plan to extend
  89. the repertoire (and to implement defined functions) as the need arises;
  90. ideally, a standard such as GKS should be adopted, if we want fo
  91. accommodate applications with more drawing requirements.  The is nothing
  92. in the interface definition which precludes color drawing.
  93.  
  94. Although the documentation clearly describes the interface to a library
  95. of C functions, it shouldn't be to hard to translate the interface to
  96. other languages like FORTRAN or Modula.  Ideally, STDWIN should be
  97. defined as a set of 'abstract' functions for which language bindings can
  98. be provided, similarly to the definition of GKS.
  99.  
  100. --- Postscript ---
  101.  
  102. The general aim of STDWIN is to provide high-level features to
  103. applications which can be used with little effort.  Features provided
  104. must be implementable on top of a large number of window managers;
  105. therefore, no precise definitions of some semantical aspects of windows
  106. can be given, in order not to rule out certain implementations (example:
  107. there can be no mention of a 'stack' of windows, since we want to be
  108. compatible with tiling window managers).  This may impair the freedom of
  109. applications, but will enforce a useful standardization of applications
  110. running on a particular system.
  111.  
  112. In many cases STDWIN provides a way to change the default behaviour
  113. if this is considered useful for the application; sometimes such
  114. default-changing routines have an optional or approximate effect,
  115. depending on whether they can be implemented on a particular system.
  116. For best effect this may require some system-dependent tuning when an
  117. application is ported.
  118.  
  119. DEFINITIONS OF TERMS
  120. --------------------
  121.  
  122. Here are short definitions of many of the terms used in the descriptions
  123. below.  Not all of these definitions are as precise as they could or
  124. should be.  Suggestions for improvement (also about the order of
  125. presentation) are welcome.
  126.  
  127. Window
  128.     A (usually) rectangular area on the screen which contains a view
  129.     on a document.  A window is linked to one particular document;
  130.     it has a title and 'borders', which usually contain scroll bars,
  131.     a grow box and possibly other controls and indicators.  The end
  132.     user may usually change a window's position and size, as well as
  133.     the part of the document onto which the window gives a view.
  134.  
  135. Document
  136.     The (abstract) data structure onto which a window gives a view.
  137.     A document is a rectangular portion of the plane, with maximum h
  138.     and v coordinates which can be set by the application, but it is
  139.     NOT a bitmap: a document may be much larger than the largest
  140.     bitmap that fits in main memory, and it is defined by a 'draw
  141.     procedure'.
  142.  
  143. Window tag
  144.     A small (16-bit) integer used to distinguish windows.  It is set
  145.     by the application.
  146.  
  147. Draw procedure
  148.     The function that defines a document.  When called with the
  149.     coordinates of a rectangle, it should draw (at least) that part
  150.     of the document that lies within this rectangle, using the
  151.     drawing primitives provided by STDWIN, e.g. wdrawline()
  152.     and wdrawtext().
  153.  
  154. Document coordinates
  155.     All coordinates passed to and from STDWIN functions use a
  156.     coordinate system called 'document coordinates'.  These are
  157.     derived through translation from window or screen coordinates:
  158.     the origin of the document is called (0, 0), independent of its
  159.     position on the screen or in the window.  This origin is
  160.     positioned in the UPPER left corner of the document, with the
  161.     positive horizontal (h) axis pointing right and the positive
  162.     vertical (v) axis pointing DOWN.  Document coordinates are
  163.     specified as integers.
  164.  
  165. Pixels
  166.     Are the units of measurement of document (and other)
  167.     coordinates.  The size of a pixel is system-dependent; on most
  168.     screens it is equal to a screen pixel, but on alphanumeric
  169.     displays it equals a character.  There is no guarantee that the
  170.     physical width and height of a pixel are the same; i.e., a
  171.     rectangle with equal width and height measured in pixels need
  172.     not look square on the screen.
  173.     The term pixel is also used to refer to a black or white dot on
  174.     the screen.
  175.  
  176. Text attributes
  177.     The set of parameters that affect the appearance of characters
  178.     drawn on the screen with wdrawtext() and friends.  This may
  179.     include font (e.g., Times), stylistic variation (e.g., Italic),
  180.     point size (e.g., 12), and other variations such as underlining
  181.     and inverse video.  The exact set of parameters used is
  182.     system-dependent.  Text attributes are used both by the text
  183.     drawing functions and by the text measuring functions; the
  184.     latter allow an application to calculate the size of a text
  185.     string or paragraph before it is drawn.
  186.  
  187. Text caret
  188.     Each window can have an associated 'text caret'.  This is an
  189.     indicator of where the next character would be inserted.  Its
  190.     appearance is system-dependent; on alphanumeric displays it is
  191.     usually a blinking square or underline positioned at the next
  192.     character position; on bitmapped displays it is usually a
  193.     blinking vertical line just before the next character position.
  194.     There is at most one text caret per window; only the active
  195.     window's caret blinks (or is visible at all).
  196.     (The name 'caret' is used instead of 'cursor' because the latter
  197.     word also refers to the arrow or other symbol moved by the
  198.     mouse.  The name seems to be taken from the symbol actually used
  199.     for its function in Smalltalk-80, which looks like a '^' at the
  200.     baseline pointing at the insert position between two characters.)
  201.  
  202. Event
  203.     Any form of interactive input to the application, reported by
  204.     wgetevent().  Events include keys pressed on the keyboard, menu
  205.     selections, mouse clicks, but also the fact that a new window
  206.     has become 'active'.
  207.  
  208. Active window
  209.     The window to which most events apply.  It is usually displayed
  210.     with a special highlighting of its border or title, and on
  211.     overlapping window systems it is usually the frontmost window,
  212.     and thus visible in its entirety.  At any time there is at most
  213.     one active window.  The application has little or no influence
  214.     over which window is active, since the end user may randomly
  215.     select a window and activate it.  In a multi-programming
  216.     environment, where the screen is shared by several applications,
  217.     at most one application has an active window, and only this
  218.     application will receive keyboard events.
  219.  
  220. CONVENTIONS
  221. -----------
  222.  
  223. For the benefit of the user of the STWIN library there are some
  224. conventions about naming of functions, parameter order and so on; these
  225. also restrict and guide the design of further additions to the library
  226. (without restricting the expressive power; they are just conventions of
  227. form).
  228.  
  229. - Names of functions, parameters, variables, structure tags and
  230.   structure members are written in lower case.
  231. - Type names and constants are written in UPPER CASE.
  232. - Underscores are not used in names, except in defined constants.
  233.  
  234. - Names of structured types are written in upper case, e.g. WINDOW,
  235.   EVENT.  Such names always denote the struct itself; pointer types are
  236.   made by appending an asterisk, e.g. WINDOW *.
  237. - All functions (except the textedit package) have a name beginning with
  238.   'w'.
  239. - Enquiry functions have a name beginning with 'wget'; corresponding
  240.   changing functions begin with 'wset'.
  241.  
  242. - Standard abbreviations (used in function and parameter names):
  243.   'attr'    attribute
  244.   'bool'    boolean
  245.   'buf'        buffer
  246.   'def'        default
  247.   'doc'        document
  248.   'h'        horizontal
  249.   'len'        length (of a string)
  250.   'pos'        position
  251.   'scr'        screen
  252.   'str'        string
  253.   'v'        vertical
  254.   'win'        window
  255. - When a word has an abbreviation, the abbreviation should be used
  256.   consistently.
  257. - Most other words are written unabbreviated.
  258.  
  259. - Coordinates are given in the order (horizontal, vertical); sizes in
  260.   the order (width, height).  Distances are given as (dh, dv).
  261. - Rectangles are given as (left, top, right, bottom).  The pixels at the
  262.   right and bottom borders are not contained in the rectangle.  I.e.,
  263.   the rectangle (0, 0, 0, 0) contains no pixels; the rectangle
  264.   (0, 0, 1, 1) contains one pixel, at position (0, 0).
  265. - Angles [how are these defined - gbl]
  266.  
  267. - When a function has a window pointer as parameter, it is the first
  268.   parameter.
  269. - When a function has a string parameter and a length of the same, the
  270.   length parameter immediately follows the string parameter.  A negative
  271.   length indicates that the string's length is to be computed by
  272.   strlen() (this should work in all such cases).
  273. - When a function has one or more output parameters, these parameters
  274.   (of type 'pointer to ...') have a name beginning with 'p', e.g.
  275.   pwidth, pheight.
  276. - When a function has a struct as parameter, its address is passed,
  277.   even if only its value is used.  [This rule is in part based on the
  278.   old C standard, which has shaped common practice amongst C
  279.   programmers, in part on efficiency considerations.]
  280.  
  281. The textedit package has some private conventions:
  282.  
  283. - All textedit function names start with 'te'.
  284. - The pointer to the TEXTEDIT structure is the first parameter.
  285.  
  286. DATA STRUCTURES
  287. ---------------
  288.  
  289. The following data structures are defined in <stdwin.h>.
  290.  
  291. WINDOW *
  292.     A pointer to a WINDOW structure, whose contents is
  293.     implementation-defined.  It is used to identify the window that
  294.     an operation applies to.
  295.  
  296. TEXTATTR
  297.     struct textattr {
  298.         ...
  299.     };
  300.     An implementation-defined structure containing all parameters
  301.     to the text drawing and measuring functions.
  302.  
  303. EVENT
  304.     struct event {
  305.         ...
  306.         int type;
  307.         int window;
  308.         union {
  309.             int character;
  310.             int command;
  311.             struct {
  312.                 int h;
  313.                 int v;
  314.                 int clicks;
  315.                 int button;
  316.                 int mask;
  317.             } where;
  318.             struct { int id; int item; } m;
  319.             struct { int left, top, right, bottom; } area;
  320.             ...
  321.         } u;
  322.         ...
  323.     };
  324.     A structure with mostly well-known members (although their
  325.     types may differ slightly, e.g. short or unsigned instead of
  326.     int, and more members may be actually present).  It contains
  327.     information about an `event'.
  328.  
  329. TEXTEDIT
  330.     struct textedit {
  331.         ...
  332.         char *text;
  333.         int foc1, foc2;
  334.         int left, top, right, bottom;
  335.         int nbreaks;
  336.         ...
  337.     };
  338.     A structure with some well-known and some private members.  It
  339.     contains sufficient information for the `textedit' package to do
  340.     simple editing operations on the text.  [Note: the well-known
  341.     members should really be hidden as well, and accessed only
  342.     through access functions!]
  343.  
  344. MENU *
  345.     A pointer to a menu definition.  It is returned by wmenucreate()
  346.     and used to refer to the menu in all further calls that affect a
  347.     particular menu, e.g. wmenuadditem().
  348.  
  349. LIMITATIONS
  350. -----------
  351.  
  352. - STDWIN library functions don't check their arguments for illegal
  353.   values, such as NULL or invalid window pointers or NULL string
  354.   pointers.  Such parameters are in error and may cause crashes or other
  355.   strange behaviour.  An exception is made for coordinates: these are
  356.   clipped to the valid drawing area, if necessary.
  357. - The STDWIN library makes freely use of statically allocated data; it
  358.   is not reentrant.  Signal handlers should not call longjmp (and
  359.   neither should draw procedures), nor any STDWIN function, when it is
  360.   possible that a STDWIN function is already active.  An exception is
  361.   wdone(), which may be called from a signal handler at any time (even
  362.   before winit() is called or while it is executing), provided no more
  363.   calls to STDWIN follow and the handler termiates the program in some
  364.   way (e.g., by calling exit() or abort()).  (In return, the STDWIN
  365.   library will not call the draw procedure except from wgetevent().)
  366. - Most functions do not report any error condition.  If they can't
  367.   perform their function due to some semantic constraint, they just do
  368.   nothing.  Functions that return pointers will return NULL pointers
  369.   in such cases.  Similar for out-of-memory conditions; these will not
  370.   cause immediate crashes but are not reported back directly either.
  371.   (It will be possible to substitute one's own memory allocator which
  372.   could set an error flag when it detects a memory shortage; there
  373.   should also be a user function to be called whenever an error is
  374.   detected.)
  375. - STDWIN functions may actually be implemented as macros.  It is not
  376.   guaranteed that the arguments are evaluated exactly once!
  377. - The current versions of the library has many external names that
  378.   shouldn't be visible to the application, or at least should start with
  379.   an unlikely combination such as '_w_'.  My apologies.  This'll change
  380.   eventually.
  381.  
  382. USAGE
  383. -----
  384.  
  385. [NOTE: the information in this section is out of date; the versions
  386. described here are ancient!]
  387.  
  388. All definitions for the STDWIN library are contained in the header file
  389. <stdwin.h>.  All routines are to be found in compiled form in the
  390. library file "libstdwin.a".  These reside in system-dependent
  391. directories; you might try the following options to cc (on boring and
  392. tango):
  393.  
  394.     G=~guido
  395.     cc -I$G/include <files> $G/lib/libstdwin.a
  396.  
  397. This gets you the termcap version on boring, but the true windowing
  398. version on tango.
  399.  
  400. ROUTINES
  401. ========
  402.  
  403. The following routines are available to the application programmer.
  404. Routines marked with [*] are not available in the first
  405. implementation(s).
  406.  
  407.  
  408. INITIALIZATION
  409. --------------
  410.  
  411. void winitnew( &argc, &argv );
  412.     Initializes the STDWIN library.  Required before any STDWIN
  413.     calls.  Should be called only once per program run. The pointers
  414.     to argc and argv allow some implementations of STDWIN to grab
  415.     command line arguments without the program knowing.
  416.  
  417. void wdone();
  418.     Ends use of the STDWIN library.  Removes open windows and resets
  419.     any special system state set by STDWIN.  Required once winit()
  420.     has been called; safe to call before winit() has been called.
  421.     Also safe to call within signal handlers.
  422.  
  423. SCREEN PROPERTIES
  424. -----------------
  425.  
  426. void wgetscrsize(int *pwidth, *pheight);
  427.     Reports the size of the screen in pixels.  This is usually
  428.     larger than the largest window size, since windows have borders.
  429.  
  430. void wgetscrmm(int *pmmhor, *pmmvert);
  431.     Reports the approximate size of the screen in millimeters.  This
  432.     may be used to scale documents to true life size, or to
  433.     determine the screen's aspect ratio.  Note that this information
  434.     may be unavailable or inaccurate; if unavailable, the size of an
  435.     average monitor is reported.
  436.  
  437.  
  438.  
  439. WINDOW CREATION
  440. ---------------
  441.  
  442. WINDOW *wopen(char *title, void (*drawproc)());
  443.     Opens a window.  Displays the title in the window border.  The
  444.     draw procedure is remembered for later use to process window
  445.     refreshes.  Returns a pointer to the window structure.  The
  446.     window becomes the active window (this will normally cause a
  447.     WE_ACTIVATE event the next time wgetevent() is called).  The
  448.     content area of the window will be redrawn (by calling the draw
  449.     procedure) by a call to wgetevent() in the near future.  The
  450.     window receives the current default text attributes as its
  451.     text attributes.  Passing a NULL pointer as the drawproc changes
  452.     the treatment of window redrawing: whenever part of a window
  453.     must be redrawn, a WE_DRAW event is generated.
  454.  
  455. void wclose(WINDOW *win);
  456.     Disposes of a window and associated data structures.  Some other
  457.     window may become the active window (and a WE_ACTIVATE event is
  458.     then generated).
  459.  
  460. void wupdate(WINDOW *win);
  461.     Causes the window's content area to be redraw (by calling its
  462.     draw procedure) insofar as necessary.  This may be used to show
  463.     changes in a document without calling wgetevent(); it is called
  464.     automatically by wgetevent() for all open windows (with non-NULL
  465.     draw procedures) when that routine finds no other immediate
  466.     events.
  467.  
  468.  
  469. WINDOW DEFAULT PROPERTIES
  470. -------------------------
  471.  
  472. These functions should be called before wopen() if they are to have the
  473. desired effect.  Calling them with specific parameters before each call
  474. to wopen() gives an application precise control over window properties
  475. (if the STDWIN implementation allows it).
  476.  
  477. void wsetdefwinsize(int width, height);
  478.     Sets the initial size of any windows created subsequently.  This
  479.     request may be ignored or have an approximate effect only,
  480.     depending on the STDWIN implementation.
  481.  
  482. void wsetdefwinpos(int h, v);
  483.     Sets the initial position of the top left corner of any
  484.     windows created subsequently (in screen coordinates).  Same
  485.     restrictions as for wsetdefwinsize() above apply.  Moreover,
  486.     the window creation process may try to avoid creating windows
  487.     that overlap completely, by offsetting the default position
  488.     slightly after each window is created.
  489.  
  490. void wsetmaxwinsize(int width, height);
  491.     Sets the maximum size of any windows created subsequently.  This
  492.     may be important for certain STDWIN implementations where memory
  493.     proportionally to the maximum window size is allocated for a
  494.     window when it is created.  Same restrictions as for
  495.     wsetdefwinsize() above apply.  It is not possible to change a
  496.     window's maximum size once it has been created.  {I wish this
  497.     restriction were not necessary, but the Whitechapel requires
  498.     allocation of a bitmap of the maximum window size when a window
  499.     is created, unless I have overlooked something in the
  500.     documentation.  The screen size is 1K x 1K pixels, which would
  501.     require a 128K bitmap!}
  502.  
  503. [Note: if an implementation has other properties for windows that an
  504. application might want to set a default or a specific value for each
  505. window, there should be similar functions to set such values.
  506. Preferably a standard should emerge for such properties.]
  507.  
  508.  
  509. WINDOW ACTIVATION
  510. -----------------
  511.  
  512. void wsetactive(WINDOW *win);
  513.     Changes the active window to the specified window. This allows
  514.     the application (instead of the user) to choose the active
  515.     window. You do not need to call this function in response to
  516.     a WE_ACTIVE event; it is done automatically.
  517.  
  518. WINDOW *wgetactive();
  519.     Returns a pointer to the current active window.
  520.  
  521. WINDOW PROPERTIES
  522. -----------------
  523.  
  524. void wsettag(WINDOW *win, short tag);
  525.     Sets a window's 'tag' to the specified value.  This is a field
  526.     that the application can set to any 16-bit value; probably the
  527.     best use one can make of it is to use it as a 'document index'
  528.     so a program with multiple windows can find its own data
  529.     structures belonging to a particular window.  The initial value
  530.     is zero.  Note that it is a 16-bit value to discourage storing a
  531.     pointer in it (which would introduce a serious portability
  532.     problem on machines where pointers are larger than the largest
  533.     size integer).
  534.  
  535. short wgettag(WINDOW *win);
  536.     Returns the window's 'tag', as set by the last call to wsettag()
  537.     for this window.  This is often a macro, so you needn't worry
  538.     about its speed.
  539.  
  540. void wsettitle(WINDOW *win, char *title);
  541.     Displays a new title in the window's border.
  542.  
  543. void wgetwinsize(WINDOW *win, int *pwidth, *pheight);
  544.     Reports the width and height of the window's contents area.
  545.     (that's the part of the document that's visible, not the entire
  546.     document!)
  547.     (Note that most window managers allow the user to resize a
  548.     window, so this information is only valid for a limited time.
  549.     WE_SIZE events make it possible to keep track of a window's size
  550.     changes.)
  551.  
  552. void wgetwinpos(WINDOW *win, int *ph, *pv);            [*]
  553.     Reports the position of the window's upper left corner relative
  554.     to the screen's upper left corner.  Same remarks as wgetwinsize().
  555.     [ Why isn't this a macro? - gbl ]
  556.  
  557. void wgetwinorigin(WINDOW *win, int *ph, *pv);            [*]
  558.     Reports the position of the window's upper left corner in
  559.     document coordinates [i.e., an indication for the position of
  560.     the scroll bars].  Same remarks as wgetwinsize().
  561.  
  562. [Should there be corresponding functions wsetwinsize, wsetwinpos etc.?]
  563.  
  564.  
  565. DOCUMENT CONTENTS
  566. -----------------
  567.  
  568. void wsetdocsize(WINDOW *win, int width, height);
  569.     Tells the size of the document; this is needed so that the
  570.     window manager can put up proper scroll bars.  When not set,
  571.     the document size is assumed to be equal to the maximum window
  572.     size.
  573.  
  574. void wchange(WINDOW *win, int left, top, right, bottom);
  575.     Tells the STDWIN library that the indicated rectangle of the
  576.     document needs to be redrawn.  The actual redraw is delayed
  577.     until the first call to wupdate() for the window, or a call to
  578.     wgetevent() that doesn't find a high priority event in its
  579.     queue.
  580.  
  581. void wsetorigin(WINDOW *win, int h, v);
  582.     Moves the view that the window gives on the document so that the
  583.     point (h, v) is displayed in the upper left corner of the
  584.     window.  (h, v) are clipped to lie within the document.
  585.  
  586. void wshow(WINDOW *win, int left, top, right, bottom);
  587.     Tries to scroll the window to put the given rectangle on the
  588.     screen.
  589.  
  590. void wscroll(WINDOW *win, int left, top, right, bottom, int dh, dv);
  591.     Scrolls the given rectangle by the amount (dh, dv).  No pixels
  592.     outside the rectangle are affected; pixels scrolled out are
  593.     lost, pixels scrolled in are erased.  This may be replaced by a
  594.     call to wshow with the same values for the first 5 parameters.
  595.  
  596.  
  597. TEXT ATTRIBUTES
  598. ---------------
  599.  
  600. [Certain bits of information are repeated here over and over.  How to
  601. avoid this?]
  602.  
  603. void wgetwintextattr(WINDOW *win, TEXTATTR *attr);
  604.     Retrieves the window's text attributes.  There is not much one
  605.     can do with these except pass them to wsetwintextattr() and
  606.     wsettextattr().
  607.  
  608. void wsetwintextattr(WINDOW *win, TEXTATTR *attr);
  609.     Changes the window's text attributes.  A window's text
  610.     attributes are used to initialize the (global) default
  611.     attributes when its draw procedure is called.
  612.  
  613. The following functions have a double meaning: when called from outside
  614. a draw procedure, they affect the global default text attributes; when
  615. used within a draw procedure (when it is called from wgetevent()), they
  616. affect the current text attributes, that are also used by wdrawtext()
  617. and the text measuring functions.  These current text attributes are
  618. initialized to the window's text attributes before the draw procedure
  619. is called; but the window's text attributes are not restored from the
  620. final value of the current text attributes (to change a window's text
  621. attributes, use wsetwintextattr()).
  622.  
  623. To change a window's text attributes, one could do the following
  624. (outside the draw procedure):
  625.  
  626.     TEXTATTR saveattr, winattr;
  627.     wgettextattr(&saveattr);    /* Save current default attrs */
  628.     wgetwintextattr(&winattr);    /* Get window's attrs */
  629.     wsettextattr(&winattr);        /* Use them as new current attrs */
  630.     
  631.     wsetbold();    /* Or whatever; change current attrs here */
  632.     ...
  633.     
  634.     wgettextattr(&winattr);        /* Get changes attrs */
  635.     wsetwintextattr(&winattr);    /* Store them in the window */
  636.     wsettextattr(&saveattr);    /* Restore saved defaults */
  637.  
  638. [Sorry if this looks complicated.  It's easier to change the defaults
  639. before you create the window...]
  640.  
  641. void wsetplain();
  642. void wsetbold();
  643. void wsetitalic();
  644. void wsetbolditalic();
  645. void wsethilite();
  646. void wsetinverse();
  647. void wsetunderline();
  648.     These functions select the text drawing style.  Setplain()
  649.     resets the style to default; the others (attempt to) select a
  650.     particular alternate style.  At least one alternate style is
  651.     available.  When a particular alternate style is unavailable,
  652.     another alternate style (but not plain) is chosen.  Wsethilite
  653.     chooses an alternate style that is particularly suitable to the
  654.     given screen.
  655.  
  656. void wsetfont(char *font);                    [*]
  657. void wsetpointsize(int size);                    [*]
  658.     [Is this a reasonable interface to select fonts?  E.g.
  659.         wsetfont("times");
  660.         wsetpointsize(12);
  661.     Or is it better to combine the two, e.g.
  662.         wsetfont("times", 12);
  663.     Is there a need for non-integral point sizes?  I've heard about
  664.     phototypesetters that have half-point size increments...]
  665.  
  666. void wgettextattr(TEXTATTR *attr);
  667.     Report the current text attributes.  These are the global default
  668.     text attributes when called from outside a draw procedure, the
  669.     current drawing text attributes inside a draw procedure.
  670.  
  671. void wsettextattr(TEXTATTR *attr);
  672.     Set the current text attributes (from a value previously
  673.     retrieved with wgettextattr() or wgetwintextattr()).  Same
  674.     remark as for wgettextattr().
  675.  
  676.  
  677. TEXT MEASURING
  678. --------------
  679.  
  680. The text measuring functions can be used inside or outside a draw
  681. procedure.  Outside, they use the global default text attributes;
  682. inside, they they use the current text attributes (initialized from the
  683. window's text attributes).
  684.  
  685. int wlineheight();
  686.     Returns the height, in pixels, of a text line in the current
  687.     font, style and point size.  This includes the ascent, descent
  688.     and extra line spacing, so that text lines whose baselines or
  689.     top lines differ by this much look 'right' (you may have a
  690.     different opinion, though).
  691.  
  692. int wtextwidth(char *str, int len);
  693.     Returns the width (in pixels) of the string 'str', of length
  694.     'len', when it would be drawn using the current text attributes.
  695.     Note that the width of a string may differ (slightly) from the
  696.     sum of the widths of its characters, due to kerning and other
  697.     magic that goes on during character drawing.  Different selected
  698.     text styles or other attributes also affect the outcome.  It is
  699.     guaranteed, however, that wtextwidth() gives the same result as
  700.     the width reported (implicitly) by wtextdraw() using the same
  701.     text attributes.
  702.  
  703. int wcharwidth(char c);
  704.     Similar to wtextwidth(), but for one character.
  705.  
  706. int wtextbreak(char *str, int len, int width);
  707.     Returns the number of characters string string 'str', of length
  708.     'len', that would fit in 'width' pixels, when drawn with the
  709.     current text attributes.  (This is useful when trying to break
  710.     the lines of a paragraph of text, for instance; this call is
  711.     faster than repeated calls to wtextwidth() until the given width
  712.     is exceeded.)
  713.  
  714.  
  715. THE DRAW PROCEDURE
  716. ------------------
  717.  
  718. The draw procedure that was passed as a parameter to wopen() is called
  719. by wgetevent() when it needs to refresh part of the document.  It should
  720. be declared as follows:
  721.  
  722. void drawproc(WINDOW *win, int left, top, right, bottom);
  723.  
  724. The draw procedure should draw at least that part of the document that
  725. lies within the given rectangle (in document coordinates).  It may draw
  726. more, even all of the document, but this may slow down the drawing
  727. process considerably.  It can use the drawing operations described
  728. below, the text measuring functions and the text attribute functions
  729. described above, and the window and screen property enquiries described
  730. far above.  It should not call any other STDWIN functions.
  731.  
  732. DRAWING OPERATIONS
  733. ------------------
  734.  
  735. Before calling any of the drawing primitives from outside of a drawing
  736. procedure, the application should call wbegindrawing() to signal which
  737. window it is drawing in. Output will not be flushed to the process
  738. until a corresponding call to wendrawing(), or a call to wflush().
  739. A drawing procedure being called by STDWIN will have this done
  740. automatically.
  741.  
  742. void wbegindrawing(WINDOW *win);
  743.     Signals start of drawing.
  744.  
  745. void wendrawing( WINDOW *win);
  746.     Signals end of drawing, and flushes output to window.
  747.  
  748. void wflush();                            [*]
  749.     Flushes output during drawing.
  750.  
  751. Note: none of following operations is currently implemented in the termcap
  752. version, and most will probably remain dummies anyway.
  753.  
  754. void wdrawline(int h1, v1, h2, v2);
  755.     Draws a line from (h1, v1) to (h2, v2).  Specifying h1==v1 and
  756.     h2==v2 plots a point.
  757.  
  758. void wxorline(int h1, int v1, int h2, int v2);
  759.     Draws a line from (h1, v1) to (h2, v2), inverting all points
  760.     in the line, such that pixels which were previously dark are
  761.     now light and vice-versa.
  762.  
  763. void wdrawbox(int left, top, right, bottom);
  764.     Draws a rectangular box that lies just *inside* the given
  765.     rectangle.  Don't call with left >= right or top >= bottom.
  766.  
  767. void wdrawcircle(int h, v, radius);
  768.     Draws a circle with center (h, v) and given radius.
  769.  
  770. void werase(int left, top, right, bottom);
  771.     Erases the given rectangle.
  772.  
  773. void wpaint(int left, top, right, bottom);
  774.     Paints the given rectangle black.
  775.  
  776. void wshade(int left, top, right, bottom, int percentage);
  777.     Shades the given rectangle with a colour grey that approximates
  778.     the given percentage; 0 is white, 100 is black.  Unlike
  779.     werase(), wshade() does not clear any pixels, it just adds black
  780.     pixels; so lightly shading an area where a text has already been
  781.     drawn gives the effect of text on a shaded background.  (The
  782.     reverse drawing order also works.)
  783.  
  784. void winvert(int left, top, right, bottom);
  785.     Inverts the pixels in the given rectangle.
  786.  
  787. void wdrawelarc(int h, int v, int radh, int radv,
  788.     int angle1, int angle2);
  789.     Draws an elliptical arc, with axes parallel to the horizontal
  790.     and vertical axes, starting drawing at angle1 and ending
  791.     drawing at angle2.
  792.  
  793.  
  794. TEXT DRAWING OPERATIONS
  795. -----------------------
  796.  
  797. The following routines, like the drawing primitives above, may only be
  798. used from within a draw procedure or between calls to wbegindrawing()
  799. and wenddrawing().
  800.  
  801. int wdrawtext(int h, v, char *str, int len);
  802.     Draws the text string 'str' of length 'len' starting with its
  803.     upper left corner at (h, v).  Returns the h coordinate of the
  804.     upper right corner of the drawn text.  Explanation:
  805.  
  806.     initial (h, v):
  807.     |
  808.     v                                  w
  809.     *-------------------------------------------------------* }   l
  810.     |                            |  }  i
  811.     | #########  #########  #######      #######  #########    |  }  n
  812.     | #          #          #      #    #             #    |   } e
  813.     | #######    #######    #######      ######       #    |    }h
  814.     | #          #          #      #           #      #    |   } e
  815.     | #########  ########   #       #   #######       #    |  }  i
  816.     |                            |  }  g
  817.     *-------------------------------------------------------* }   h
  818.                                 ^     t
  819.                                 |
  820.                 return h coordinate of this point:
  821.  
  822. int wdrawchar(int h, int v, char c);
  823.     Similar to wdrawtext(), but draws one character.
  824.  
  825.  
  826. THE TEXT CARET
  827. --------------
  828.  
  829. void wsetcaret(WINDOW *win, int h, v);
  830.     Declares that the window's "text caret" is to be positioned at
  831.     position (h, v).  The caret is placed such that it appears just
  832.     before a character drawn at this position.  Depending on the
  833.     possibilities of the hardware, the caret may blink.  There can
  834.     be at most one text caret per window.
  835.  
  836. void wnocaret(WINDOW *win);
  837.     Removes the window's text caret.
  838.  
  839.  
  840. EVENTS
  841. ------
  842.  
  843. void wgetevent(EVENT *ep);
  844.     Waits until the next event is available, then places
  845.     information about it in the EVENT struct pointed by 'ep' and
  846.     returns.  When no event is available immediately, it redraws
  847.     any windows that still need redrawing (as indicated by a call
  848.     to wchange() or other causes such as windows being moved by the
  849.     user) by calling wupdate() which will call their draw procedure.
  850.     It also handles menu selection, window moving and resizing and
  851.     scrolling.
  852.     
  853.     Event types are the following:
  854.     
  855.     WE_ACTIVATE
  856.         A window becomes active.  The 'window' field of the EVENT
  857.         struct indicates what window.  If this contains NULL, no
  858.         window belonging to the application is active; this is
  859.         possible in multi-process environments.
  860.     
  861.     WE_CHAR
  862.         A character has been typed on the keyboard.  Its ASCII
  863.         value can be found in the field 'u.character'.
  864.     
  865.     WE_COMMAND
  866.         A special command has been issued, usually by pressing a
  867.         special key or clicking some icon.  Codes found in the
  868.         field 'u.command' are:
  869.         
  870.         WC_CLOSE
  871.             Request to close a window.  Which window can be
  872.             found from 'e.window'.
  873.         
  874.         WC_LEFT, WC_RIGHT, WC_UP, WC_DOWN
  875.             Arrow key pressed.
  876.         
  877.         WC_CANCEL, WC_BACKSPACE, WC_TAB, WC_RETURN
  878.             Special key pressed.
  879.         
  880.         There may be other codes depending on the STDWIN
  881.         implementation.
  882.     
  883.     WE_MOUSE_DOWN
  884.         The mouse button was pressed.  The position (expressed
  885.         in document coordinates) can be found in the 'u.where'
  886.         field, subfields 'h' and 'v'.  The 'clicks' subfield
  887.         indicates whether this event is or may be part of a
  888.         multi-click sequence; its value is N if this click is
  889.         the N-th click in a multi-click sequence; N is at least
  890.         1.
  891.     
  892.     WE_MOUSE_MOVE
  893.         The mouse pointer was moved.  This event is only
  894.         reported when the mouse button is down.  The new
  895.         position can be found in the 'u.where' field.  The
  896.         'clicks' subfield is always zero.
  897.     
  898.     WE_MOUSE_UP
  899.         The mouse button was released.  This event is only
  900.         reported when the mouse button was previously down (but
  901.         it is not guaranteed that a WE_MOUSE_UP event will ever
  902.         follow when a WE_MOUSE_DOWN event is reported).  The
  903.         position can be found in the 'u.where' field.  If this
  904.         click was the N-th click in a multi-click sequence, the
  905.         'clicks' field contains N; otherwise it is 0.
  906.     
  907.     WE_MENU
  908.         A menu item was selected.  The menu id and item can be
  909.         found in the fields 'u.m.id' and 'u.m.item'.
  910.     
  911.     WE_SIZE
  912.         A window's size has changed.  The affected window can be
  913.         found in the field 'window'.  The window's new size can
  914.         be requested by calling wgetwinsize().
  915.     
  916.     WE_TIMER
  917.         A window's timer has expired.
  918.  
  919.     A STDWIN application may define more events with an
  920.     implementation-dependent meaning.  It may also define additional
  921.     implementation-dependent fields in the EVENT struct.  Most
  922.     applications should refrain from using these.
  923.  
  924. void wsettimer(WINDOW *win, int deciseconds);
  925.     Sets a window's timer to go off in a given number of tenths
  926.     of a second. A WE_TIMER event will be delivered for that window
  927.     after the timer goes off. A window has only one timer; each
  928.     succeeding call overrides the previous value. A deciseconds
  929.     value of 0 turns the timer off. The largest decisecond value
  930.     guaranteed to be supported is 32000.
  931.  
  932.  
  933. MENUS
  934. -----
  935.  
  936. There are two kinds of menus: 'global' and 'local' menus.  Global menus
  937. are available independent of which window is active; local menus must
  938. explicitly be attached to one or more windows, and are only available if
  939. they have been attached to the currently active window.  By default, all
  940. windows created are global; this can be changed by calling
  941. wmenusetdeflocal(TRUE).  Most systems have fairly low limits on the
  942. number and size of menus; 5 to 10 menus of 10 to 20 items can usually
  943. be accommodated.
  944.  
  945. MENU *wmenucreate(int id, char *title);
  946.     Creates a new menu with the given menu id and title.  The id is
  947.     used to report menu selection events for this menu, see
  948.     wgetevent() above, subsection WE_MENU.  The id should be in the
  949.     range [1..255], and differ from all other menu ids in use.
  950.     Initially, the menu contains no items.  It returns a pointer to
  951.     the menu definition, which should be used in all subsequent
  952.     calls that affect this menu; a NULL pointer is returned if the
  953.     menu couldn't be created.
  954.  
  955. int wmenuadditem(MENU *menu, char *text, int shortcut);
  956.     Adds an item to the menu.  The item's item number is one
  957.     higher than the highest item already in the menu; the first
  958.     item gets number zero.  This item number is the return
  959.     value.  Some systems interpret various punctuation characters
  960.     in the text as special flags, so it is best to limit the
  961.     text to alphanumeric characters and space.  The item may
  962.     have a keyboard shortcut; shortcuts are usually implemented
  963.     by using an extra shift modifier ('ALT' or 'META' key) or
  964.     a prefix such as 'ESC'.  If no shortcut is desired, -1
  965.     should be passed for this parameter, otherwise a positive
  966.     ASCII code should be passed.
  967.     Items cannot be removed or reordered from a menu, nor can their
  968.     shortcuts be changed; an item's text chan be changed, see
  969.     below.
  970.     Adding an empty string to a menu creates an empty, unselectable
  971.     item, which may serve to separate groups of items in a long
  972.     menu.
  973.  
  974. void wmenusetitem(MENU *menu, int item, char *text);
  975.     Changes the text of the item to the new text.  The parameter
  976.     'item' must be the item number of an existing item in the menu.
  977.     A conventional way to temporarily disable a menu item is to set
  978.     its text to the empty string; it can be enabled again by
  979.     setting the text back to what it originally was.
  980.  
  981. void wmenudelete(MENU *menu);
  982.     Deletes the menu.  If it is a local menu, it is detached from
  983.     all windows to which it was attached.  All storage associated
  984.     with the menu is released.
  985.  
  986. void wmenuattach(WINDOW *win, MENU *menu);
  987.     Attaches a local menu to a given window.  This makes the menu
  988.     available whenever the window is active.  A menu may be attached
  989.     to as many windows as desired.  Don't use this for global menus.
  990.  
  991. void wmenudetach(WINDOW *win, MENU *menu);
  992.     Detaches a local menu from a given window.  No effect for global
  993.     menus.
  994.  
  995. void wmenusetdeflocal(bool local);
  996.     Sets the default status for subsequently created menus.
  997.     Initially, all menus created will be global.
  998.  
  999.  
  1000. DIALOG TOOLS
  1001. ------------
  1002.  
  1003. The following functions are available for simple dialogs that ask a
  1004. yes/no question or request a file name, and a few more.
  1005.  
  1006. void wmessage(char *str);
  1007.     Puts up an error message.  This may be put in a separate box in
  1008.     front of all other windows and require some user action before
  1009.     it goes away; or it may be placed in a less conspicuous position
  1010.     but stay there for a while.  When a second message is issued,
  1011.     the first is generally overwritten.
  1012.  
  1013. bool waskstr(char *prompt, char *buf, int buflen);
  1014.     Asks the user to type a text string.  The string is placed in
  1015.     buffer 'buf' of length 'buflen'; 'buf' is guaranteed to be
  1016.     zero-terminated.  The initial content of 'buf' is used as a
  1017.     default reply.  The user has the possibility to cancel the
  1018.     interaction, in which case the function returns FALSE (and buf
  1019.     is left undefined).
  1020.     
  1021.     Cancellation is implemented in a system-dependent manner; if a
  1022.     system has a conventional 'interrupt' key or key combination,
  1023.     this is generally used.  On Unix systems the interrupt character
  1024.     as set by 'stty' is used.
  1025.     
  1026.     [*] Current implementations ignore the given buffer length.  The
  1027.     buffer should be at least 256 bytes long.
  1028.  
  1029. int waskync(char *question, int def);
  1030.     Asks a question to which a yes/no answer is applicable.  The
  1031.     user may also cancel the interaction.  Return values are: 1 for
  1032.     yes, 0 for no, -1 for cancelled.  The parameter 'def' is the
  1033.     default reply (chosen when the users presses return without
  1034.     typing anything) and should also be one of -1, 0 or 1, with the
  1035.     same meaning.
  1036.  
  1037. bool waskfile(char *prompt, char *buf, int buflen, bool new);
  1038.     Asks for a file name.  The file name is returned into buffer
  1039.     'buf' of length 'buflen' (which is zero-terminated).  The
  1040.     initial content of 'buf' is used as a default file name.  The
  1041.     'new' parameter determines checks made on the file: when FALSE,
  1042.     the file must exist and be readable; when TRUE, the file must
  1043.     not exist but should be creatable, or it must be readable (and
  1044.     if it exists, the user is asked for confirmation to overwrite
  1045.     it).  It is not guaranteed but very probable that a subsequent
  1046.     fopen() of the file will succeed.  If the user cancels the
  1047.     interaction, the function returns FALSE and the content of 'buf'
  1048.     is undefined.
  1049.  
  1050. void wperror(char *name);
  1051.     Shows an I/O error message based on the current value of
  1052.     'errno' and the string 'name', possibly like the corresponding
  1053.     Unix function: "name: <cryptic error message>".  The message is
  1054.     put out in a similar style as messages put out by wmessage().
  1055.  
  1056.  
  1057. OTHER OUTPUT ROUTINES
  1058. ---------------------
  1059.  
  1060. This lone routine generates output which isn't associated with any
  1061. particular window. It does not have to be called from in a drawing
  1062. routine.
  1063.  
  1064. void wfleep();
  1065.     Rings the "bell" on the user's terminal.
  1066.  
  1067.  
  1068. TEXTEDIT TOOLS
  1069. --------------
  1070.  
  1071. These allow small sections of text (usually one or a few lines or
  1072. paragraphs only) to be manipulated in a standard way.  The text has a
  1073. 'focus', which is used like the Macintosh text focus.  All routines that
  1074. change the text make appropriate calls to wchange(); for these to be
  1075. effectuated the draw procedure should call tedraw() for each text edit
  1076. struct that belongs to a given window.
  1077.  
  1078. [ Note: these have been changed extensively. All new routines are mentioned
  1079. below, without any comments. Sorry. ]
  1080. TEXTEDIT *tealloc(WINDOW *win, int h, v, width);
  1081.     Allocates an empty text edit structure in the given window or
  1082.     width 'width' with its upper left corner at (h, v).  It is set
  1083.     up to use the window's current text attributes.  If allocation
  1084.     fails, it returns a NULL pointer.
  1085.  
  1086. TEXTEDIT *tecreate(WINDOW *win, int h, v, right, bottom);
  1087.  
  1088. void tefree(TEXTEDIT *te);
  1089.     Deallocates the given textedit structure.
  1090.  
  1091. void tedestroy(TEXTEDIT *te);
  1092.  
  1093. void tesetfocus(TEXTEDIT *te, int foc1, foc2);
  1094.     Sets the 'focus' from the position before character 'foc1' to
  1095.     the position before character 'foc2'.  I.e., if foc1==foc2, the
  1096.     focus contains no characters but is an 'insert focus'.  If foc2
  1097.     is larger than the number of characters in the text, it is set
  1098.     to the end of the text.
  1099.  
  1100. void tereplace(TEXTEDIT *te, char *str);
  1101.     Replaces the characters from foc1 to foc2-1 in the text by the
  1102.     contents of string 'str'.  The new focus is set after the last
  1103.     character of the inserted string.  This is effectively a delete
  1104.     of 'str' is empty, or an insert if the focus is an insert focus.
  1105.  
  1106. void tebackspace(TEXTEDIT *te);
  1107.     Deletes the focus when it contains at least a character;
  1108.     otherwise, deletes the character before the focus, if any.  The
  1109.     new focus is an insert position at the first deleted character.
  1110.  
  1111. bool teclick(TEXTEDIT *te, int h, v);
  1112.     Places the focus at the text position corresponding to the point
  1113.     (h, v).  Returns FALSE if (h, v) is outside the text's
  1114.     rectangle, and then the focus is unchanged (but a position
  1115.     beyond the end of the last line selects an insert focus at the
  1116.     end of the text).
  1117.  
  1118. bool teclicknew(TEXTEDIT *te, int h, v, bool extend);
  1119.  
  1120. bool tedoubleclick(TEXTEDIT *tp, int h, int v);
  1121.  
  1122. void tearrow(TEXTEDIT *te, int code);
  1123.     Performs the effect of an arrow key on the focus.  In 'code' the
  1124.     code of an arrow key should be given as reported by wgetevent()
  1125.     (subsection WE_COMMAND).
  1126.  
  1127. bool teevent(TEXTEDIT *te, EVENT *ep);
  1128.     If the event is applicable to the textedit record, executes it
  1129.     and returns TRUE, otherwise returns FALSE.  Applicable events
  1130.     are (at least): WE_MOUSE_DOWN, WE_CHAR, and WE_COMMAND with
  1131.     command codes for arrows, WC_BACKSPACE and WC_RETURN.  After a
  1132.     WE_MOUSE_DOWN event, this may eat subsequent WE_MOUSE_MOVE and
  1133.     a WE_MOUSE_UP event.
  1134.  
  1135. void tedraw(TEXTEDIT *te);
  1136.     Should be called only in a draw procedure, to draw the entire
  1137.     text rectangle.
  1138.  
  1139. void tedrawnew(TEXTEDIT *te, int left, top, right, bottom);
  1140.  
  1141. int tegetlen(TEXTEDIT *tp);
  1142.  
  1143. char *tegettext(TEXTEDIT *te);
  1144.     Returns a pointer to the entire text contained in the textedit
  1145.     struct.  This should only be used to make a copy of the text;
  1146.     the text may float around in memory.
  1147.  
  1148. char *tegetselection(te);                    [*]
  1149.     Returns a pointer to a copy of the text contained in the text
  1150.     selection.  This pointer points to memory that has been
  1151.     allocated with malloc() and should eventually be freed by the
  1152.     caller with free().
  1153.  
  1154. void temove(TEXTEDIT *te, int h, v, width);
  1155.     Moves the textedit struct to a new place in the document.  The
  1156.     point (h, v) is the new top left corner, while 'width' is the
  1157.     new width.
  1158.  
  1159. void temovenew(TEXTEDIT *tp,
  1160.         int left, int top, int right, int bottom);
  1161.  
  1162. int tegetnlines(TEXTEDIT *te);
  1163.     Returns the number of lines contained in the textedit struct.
  1164.     This includes any line breaks inserted to make the text fit in
  1165.     the given width.
  1166.  
  1167. int tegetfoc1(TEXTEDIT *te);
  1168. int tegetfoc2(TEXTEDIT *te);
  1169.     These return the beginning and end of the text focus, as set by
  1170.     tesetfocus() or other calls.
  1171.  
  1172. int tegetleft(TEXTEDIT *te);
  1173. int tegettop(TEXTEDIT *te);
  1174. int tegetright(TEXTEDIT *te);
  1175. int tegetbottom(TEXTEDIT *te);
  1176.     These return the coodinates of the four corners of the
  1177.     rectangle in which the text is being displayed.
  1178.  
  1179. void tesetbuf(TEXTEDIT *tp, char *buf, int buflen);
  1180.  
  1181. int wdrawpar(int h, v, char *text, int width);
  1182.     Draws a paragraph of text in a rectangle with (h, v) as its top
  1183.     left corner which is 'width' wide; it is drawn exactly the same
  1184.     as when the text would have been put in a textedit struct at the
  1185.     same position.  It returns the v coordinate of the bottom of the
  1186.     box in which the text is drawn.
  1187.  
  1188. int wparheight(char *text, int width);
  1189.     Returns the height of a paragraph of text (in document
  1190.     coordinates) when it would be drawn by wdrawpar using the same
  1191.     width.
  1192.  
  1193.